﻿namespace ZGLXM.ErrorCode
{
    public class ApiResult
    {
        public bool isSuc { get; set; }

        public string msg { get; set; }

        public object? data { get; set; }

        public ApiResultCode code { get; set; }

        public ApiResult(bool isSuc, string msg, object? data, ApiResultCode code)
        {
            this.isSuc = isSuc;
            this.msg = msg;
            this.data = data;
            this.code = code;
        }

        public static ApiResult OK(object? data=null, string msg = "操作成功")
        {
            return new ApiResult(isSuc:true, msg, data, ApiResultCode.Success);
        }

        public static ApiResult Fail(string msg = "操作失败")
        {
            return new ApiResult(isSuc:false, msg, data:null, ApiResultCode.Fail);
        }
    }

    public enum ApiResultCode
    {
        Success,
        Fail,
        Error
    }
}
